package negocio;

import javax.servlet.http.HttpServletRequest;

import dao.DaoException;

public class CommandFacade {

	private Comando cmd;
	
	public Object execute(Object obj) throws NegocioException, DaoException {
		return execute(obj, null);
	}

	public Object execute(Object obj, HttpServletRequest req) throws NegocioException, DaoException {
		GenericCommand command = null;
		try {
			command = (GenericCommand) Class.forName(cmd.getLocalizacao()).newInstance();
		} catch (Exception e) {
			throw new NegocioException(e);
		}
		return command.execute(obj, cmd.getCodigo(), req);
	}

	public void setCmd(Comando cmd) {
		this.cmd = cmd;
	}

	public Comando getCmd() {
		return cmd;
	}

}
